﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Collections;
using UMC.Web;
using UMC.WorkFlow;
using UMC.WorkFlow.Entities;
using UMC.Data;

namespace UMC.WorkFlow
{

    class TaskKeyDialog : UIGridDialog
    {


        protected override Hashtable GetHeader()
        {
            var header = new Header("Id", 25);
            header.AddField("Code", "标识");
            header.AddField("Caption", "名称");
            return header.GetHeader();

        }
        protected override Hashtable GetData(IDictionary paramsKey)
        {
            var start = UMC.Data.Utility.Parse((paramsKey["start"] ?? "0").ToString(), 0);
            var limit = UMC.Data.Utility.Parse((paramsKey["limit"] ?? "15").ToString(), 30);
            var searcher = HotCache.Search<TaskKey>();
            var key = paramsKey["Keyword"] as string;//    this.Keyword
            if (String.IsNullOrEmpty(key) == false)
            {
                searcher.Or().Like(new TaskKey { Caption = key, Code = key });
            }
            var data = searcher.Query(new TaskKey(), start, limit, out var nextIndex);
            var hash = new Hashtable();
            hash["data"] = data;
            hash["next"] = nextIndex > -1;
            hash["start"] = nextIndex;
            return hash;
        }
    }

}